﻿// Decompiled with JetBrains decompiler
// Type: UnityEngine.UnityLogWriter
// Assembly: UnityEngine.CoreModule, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
// MVID: E6AE6B5A-2752-4B07-9528-C8B77C62CE79
// Assembly location: C:\Users\windys\Unity\2021.3.39f1c1\Editor\Data\Managed\UnityEngine\UnityEngine.CoreModule.dll
// XML documentation location: C:\Users\windys\Unity\2021.3.39f1c1\Editor\Data\Managed\UnityEngine\UnityEngine.CoreModule.xml

using System;
using System.IO;
using System.Runtime.CompilerServices;
using System.Text;
using UnityEngine.Bindings;

#nullable disable
namespace UnityEngine
{
  [NativeHeader("Runtime/Export/Logging/UnityLogWriter.bindings.h")]
  internal class UnityLogWriter : TextWriter
  {
    [ThreadAndSerializationSafe]
    public static void WriteStringToUnityLog(string s)
    {
      if (s == null)
        return;
      UnityLogWriter.WriteStringToUnityLogImpl(s);
    }

    [FreeFunction(IsThreadSafe = true)]
    [MethodImpl(MethodImplOptions.InternalCall)]
    private static extern void WriteStringToUnityLogImpl(string s);

    public static void Init() => Console.SetOut((TextWriter) new UnityLogWriter());

    public override Encoding Encoding => Encoding.UTF8;

    public override void Write(char value)
    {
      UnityLogWriter.WriteStringToUnityLog(value.ToString());
    }

    public override void Write(string s) => UnityLogWriter.WriteStringToUnityLog(s);

    public override void Write(char[] buffer, int index, int count)
    {
      UnityLogWriter.WriteStringToUnityLogImpl(new string(buffer, index, count));
    }
  }
}
